{include file=member.header.html}
<script type="text/javascript">
//<!CDATA[
$(function(){
    $("#store_logo").val('');
    $("#store_banner").val('');
    $('#my_store_form').validate({
        errorLabelContainer: $('#warning'),
        invalidHandler: function(form, validator) {
           var errors = validator.numberOfInvalids();
           if(errors)
           {
               $('#warning').show();
           }
           else
           {
               $('#warning').hide();
           }
        },
        rules : {
            store_name : {
                required   : true,
                remote : {
                    url  : 'index.php?app=apply&act=check_name&ajax=1',
                    type : 'get',
                    data : {
                        store_name : function(){
                            return $('#store_name').val();
                        },
                        store_id : {$store.store_id}
                    }
                },
                maxlength: 30
            },
			 owner_name      : {
                required     : true
            },
			 /*pay_account_name      : {
                required     : true
            },
			 pay_account      : {
                required     : true
            },
			 pay_bank      : {
                required     : true
            },
			   region_name:{
                required:true,
                minlength:9
            },*/
			
            tel      : {
                required     : true,
                isPhone     : true
            },
            im_qq : {
                isQQ: true
            },
            description      : {
                required     : true
            },
            store_banner : {
                accept   : 'png|jpe?g|gif'
            },
            store_logo   : {
                accept   : 'png|jpe?g|gif'
            }
        },
        messages : {
            store_name  : {
                required   : '请输入店铺名称',
                remote: '{$lang.name_exist}',
                maxlength: '{$lang.note_for_store_name}'
            },
		    owner_name: {
                required: '请输入店主姓名'
            },
			/*pay_account_name: {
                required: '请输入商户结算账户名称'
            },
	        pay_account: {
                required: '请输入结算账号'
            },
	        pay_bank: {
                required: '请输入开户行'
            },*/
			
			  region_name:{
                required: '请选择所在地区',
                minlength: '请选择所在地区'
            },
			
            tel      : {
                required   : '请输入联系电话',
                isPhone   : '联系电话号码不正确'
            },
            im_qq : {
                isQQ : 'qq号码不正确. '
            },
            description    : {
                required   : '店铺简介不能为空'
            },
            store_banner : {
                accept  : '{$lang.pic_limit}'
            },
            store_logo  : {
                accept : '{$lang.pic_limit}'
            }
        }
    });
   regionInit("region");
   
   // 上传商铺LOGO
    var storeLogoOption =
    {
        // 提交目标
        action: "{$site_url}/index.php?app=member&act=ajax_uploadify",
		// 服务端接收的名称
		name: "Filedata",
        // 自动提交
        autoSubmit: true,
        // 选择文件之后…
        onChange: function (file, extension) {
            if (new RegExp(/(jpg)|(jpeg)|(gif)|(png)/i).test(extension)) {
            } else {
                alert("只限上传jpg,jpeg,gif,png格式图片文件，请重新选择！");
            }
        },
        // 开始上传文件
        onSubmit: function (file, extension) {
            $("#state").show().html("正在上传" + file + "..");
        },
        // 上传完成之后
        onComplete: function (file, response) {
            var rs = eval("("+response+")");
            if (rs.state)
            {
                var img_url = "{$site_url}/"+rs.msg;
                $("#state").hide();
                $('img[ectype="store_logo"]').attr('src', img_url);
                $("#store_logo").val(rs.msg);
            }
            else 
            {
                alert(rs.msg);
                $("#state").hide();
            }
            
        }
    }

    // 初始化图片上传框
    var oAjaxUpload = new AjaxUpload('#change_store_logo', storeLogoOption);
    
    // 上传商铺广告图片
    var storeBannerOption =
    {
        // 提交目标
        action: "{$site_url}/index.php?app=member&act=ajax_uploadify",
		// 服务端接收的名称
		name: "Filedata",
        // 自动提交
        autoSubmit: true,
        // 选择文件之后…
        onChange: function (file, extension) {
            if (new RegExp(/(jpg)|(jpeg)|(gif)|(png)/i).test(extension)) {
            } else {
                alert("只限上传jpg,jpeg,gif,png格式图片文件，请重新选择！");
            }
        },
        // 开始上传文件
        onSubmit: function (file, extension) {
            $("#state").show().html("正在上传" + file + "..");
        },
        // 上传完成之后
        onComplete: function (file, response) {
            var rs = eval("("+response+")");
            if (rs.state)
            {
                var img_url = "{$site_url}/"+rs.msg;
                $("#state").hide();
                $('img[ectype="store_banner"]').attr('src', img_url);
                $("#store_banner").val(rs.msg);
            }
            else 
            {
                alert(rs.msg);
                $("#state").hide();
            }
            
        }
    }

    // 初始化图片上传框
    var oAjaxUpload = new AjaxUpload('#change_store_banner', storeBannerOption);
        
});

function add_uploadedfile(file_data)
{
        $('#desc_images').append('<li file_name="'+ file_data.file_name +'" file_path="'+ file_data.file_path +'" ectype="handle_pic" file_id="'+ file_data.file_id +'"><input type="hidden" name="desc_file_id[]" value="'+ file_data.file_id +'"><div class="pic" style="z-index: 2;"><img src="{$site_url}/'+ file_data.file_path +'" width="50" height="50" alt="'+ file_data.file_name +'" /></div><div ectype="handler" class="bg" style="z-index: 3;display:none"><img src="{$site_url}/'+ file_data.file_path +'" width="50" height="50" alt="'+ file_data.file_name +'" /><p class="operation"><a href="javascript:void(0);" class="cut_in" ectype="insert_editor" ecm_title="{$lang.insert_editor}"></a><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p><p class="name">'+ file_data.file_name +'</p></div></li>');
        trigger_uploader();
        if(EDITOR_SWFU.getStats().files_queued == 0){
                window.setTimeout(function(){
                        $('#editor_uploader').hide();
                },5000);
        }
}
function drop_image(file_id)
{
    if (confirm(lang.uploadedfile_drop_confirm))
        {
            var url = SITE_URL + '/index.php?app=my_store&act=drop_uploadedfile';
            $.getJSON(url, {'file_id':file_id}, function(data){
                if (data.done)
                {
                    $('*[file_id="' + file_id + '"]').remove();
                }
                else
                {
                    alert(data.msg);
                }
            });
        }
}

//]]>

</script>
{$editor_upload}
{$build_editor}
<!-- 内容 -->
<div class="content f-cb">
		<!-- 当前位置 -->
		{include file=path.html}
		<!-- 内容左边栏 -->
		{include file=member.menu.html}
		<!-- 内容右边栏 -->
		<div class="con-shop-r f-cb">
        <div class="public">
          <div class="information">
            <form method="post" enctype="multipart/form-data" id="my_store_form">
                    <div class="setup">
                    <div id="state"></div>
                        <div class="photo relative1">

                            <p><img src="<!--{if $store.store_logo neq ''}-->{$store.store_logo}?{$random_number}<!--{else}-->data/system/default_store_logo.gif<!--{/if}-->" width="120" height="120" ectype="store_logo" /></p>
                            <b class="ie6hack">                               
                                <div class="txt" id="change_store_logo">{$lang.change_store_logo}</div>
                            </b>                           
                                <input type="hidden" value="" name="store_logo" id="store_logo" />
                            <span class="explain">{$lang.change_store_logo_des}</span>
                        </div>
                        <div class="photo relative2">
                            <p><img src="<!--{ if $store.store_banner neq ''}-->{$store.store_banner}?{$random_number}<!--{else}-->{res file=images/member/banner.jpg}<!--{/if}-->" width="607" height="120" ectype="store_banner" /></p>
                            <b>                           
                                <div class="txt"  id="change_store_banner">{$lang.change_store_banner}</div>
                            </b>
                            <input type="hidden" value="" name="store_banner" id="store_banner" />
                            <span class="explain">{$lang.change_store_banner_des}</span>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div id="warning"></div>
                    <div class="setup info shop">

                        <table style="width: 100%">
                            <!--{if $subdomain_enable}-->
                            <tr>
                              <th>{$lang.subdomain}:</th>
                              <td><input type="text" name="domain" value="{$store.domain|escape}"{if $store.domain} disabled{/if} class="text width11" />&nbsp;{if !$store.domain}{$lang.subdomain_note}{$domain_length}{else}{/if}</td>
                            </tr>
                            <!--{/if}-->
                            <tr>
                                <th class="width2">合作方式:</th>
                                <td>
                                    <p class="td_block"><input   type="text" class="text width_normal b-radius" disabled  value="{if $store.sgrade eq 2}佣金{else}差价{/if}"/></p>
                                </td>
                            </tr>
                            <tr>
                                <th class="width2"><b class="padding1">*</b>{$lang.store_name}:</th>
                                <td>
                                    <p class="td_block"><input id="store_name" maxlength="20" type="text" class="text width_normal b-radius" name="store_name" value="{$store.store_name|escape}"/><label class="field_notice">{$lang.store_name}</label></p>
                                    <a href="{jsurl app=store&id=$store.store_id}" target="_blank" class="btn1">{$lang.my_store_index}</a>
                                </td>
                            </tr>  
                            <tr>
                                <th class="width2"><b class="padding1">*</b>店主姓名:</th>
                                <td>
                                    <p class="td_block"><input id="owner_name" maxlength="32" type="text" class="text width_normal b-radius" name="owner_name" value="{$store.owner_name|escape}"/><label class="field_notice">请填写真实姓名</label></p>
                                </td>
                            </tr>    
                              <tr>
                                <th class="width2">结算账户:</th>
                                <td>
                                    <p class="td_block"><input disabled id="pay_account_name" maxlength="50" type="text" class="text width_normal b-radius" name="pay_account_name" value="{$store.pay_account_name|escape}"/></p>
                                </td>
                            </tr>  
                              <tr>
                                <th class="width2">结算账号:</th>
                                <td>
                                    <p class="td_block"><input disabled id="pay_account" maxlength="25" type="text" class="text width_normal b-radius" name="pay_account" value="{$store.pay_account|escape}"/></p>
                                </td>
                            </tr>  
                              <tr>
                                <th class="width2">开户行:</th>
                                <td>
                                    <p class="td_block"><input disabled id="pay_bank" maxlength="50" type="text" class="text width_normal b-radius" name="pay_bank" value="{$store.pay_bank|escape}"/></p>
                                </td>
                            </tr>  
                             <tr>
                                <th class="width2">发票抬头:</th>
                                <td>
                                    <p class="td_block"><input disabled id="pay_invoice" maxlength="50" type="text" class="text width_normal b-radius" name="pay_invoice" value="{$store.pay_invoice|escape}"/></p>
                                </td>
                            </tr>    
                             <tr>
                                <th class="width2">结算支付方式 :</th>
                                <td>
                                       
                                    <p class="td_block">
                                       <select name="pay_type">
            <!--{foreach from=$cfg_store_pay_type item=bank key=key name=v}-->
            <option value="{$key}" <!-- {if $store.pay_type eq $key} -->selected="selected"<!-- {/if} -->>{$bank}</option>
            <!--{/foreach}-->               
              </select>
                  <label class="field_notice">请选择商户结算的支付方式</label></p>
                                </td>
                            </tr>                          
                            <tr>
                                <th class="width2"><b class="padding1">*</b>{$lang.region}:</th>
                                <td><div id="region">
                                    <input type="hidden" name="region_id" value="{$store.region_id}" class="mls_id" />
                                    <input type="hidden" name="region_name" value="{$store.region_name|escape}" class="mls_names" />
                                    <!-- {if $store.store_id} -->
                                    <span>{$store.region_name|escape}</span>
                                    <input type="button" value="{$lang.edit}" class="edit_region" />
                                    <select style="display:none">
                                      <option>{$lang.select_pls}</option>
                                      {html_options options=$regions}
                                    </select>
                                    <!-- {else} -->
                                    <select class="select">
                                      <option>{$lang.select_pls}</option>
                                      {html_options options=$regions}
                                    </select>
                                    <!-- {/if} --></div>
                                </td>
                            </tr>
                            <tr>
                                <th>{$lang.address}:</th>
                                <td>
                                    <p class="td_block"><input maxlength="50" type="text" name="address" class="text width_normal b-radius" id="address" value="{$store.address|escape}" /><span class="field_notice">{$lang.address_info}</span></p>
                                </td>
                            </tr>
                           <!--   <tr>
                                <th>邮政编码:</th>
                                <td><input name="zipcode" maxlength="6" type="text" class="text width_normal b-radius" id="zipcode" value="{$store.zipcode|escape}" /></td>
                            </tr> -->
                            <tr>
                                <th><b class="padding1">*</b>{$lang.tel}:</th>
                                <td><input name="tel" maxlength="20" type="text" class="text width_normal b-radius" id="tel" value="{$store.tel|escape}" /></td>
                            </tr>
                            <tr>
                                  <th>{$lang.im_qq}:</th>
                                  <td><input name="im_qq" maxlength="15" onkeyup="this.value=this.value.replace(/\D/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))" type="text" class="text width_normal b-radius" id="im_qq" value="{$store.im_qq|escape}" /></td>
                            </tr>
                            <tr>
                                  <th>{$lang.im_ww}:</th>
                                  <td><input name="im_ww" maxlength="30" type="text" class="text width_normal b-radius" id="im_ww" value="{$store.im_ww|escape}" /></td>
                            </tr>
                            <tr style="display:none;">
                                  <th>{$lang.im_msn}:</th>
                                  <td>{if $store.im_msn}{$store.im_msn|escape} <a target="_blank" href="{url app=my_store&act=drop_im_msn}">{$lang.disable_msn}</a>{else}<a target="_blank" href="{$msn_active_url}">{$lang.active_msn}</a><span class="padding1">{$lang.msn_info}</span>{/if}</td>
                             </tr>
                             {if $store.functions.groupbuy}
							 <tr style="display:none;">
                                  <th>{$lang.enable_groupbuy}:</th>
                                  <td>
								      <input id="enable_groupbuy_0" type="radio" name="enable_groupbuy" {if !$store.enable_groupbuy}checked{/if} value="0" />
                                      <label for="enable_groupbuy_0">{$lang.no}</label>
                                      <input id="enable_groupbuy_1" type="radio" name="enable_groupbuy" {if $store.enable_groupbuy}checked{/if} value="1" />
                                      <label for="enable_groupbuy_1">{$lang.yes}</label>
                                  </td>
                             </tr>
                             {/if}
                             {if $store.functions.enable_radar}
                             <!-- goods radar  -->
                             <tr>
                                  <th>{$lang.enable_radar}:</th>
                                  <td><label>
					                 <input type="radio" name="enable_radar" value="1" {if $store.enable_radar}checked="checked"{/if} />
					                {$lang.yes}</label>
					                <label>
					                <input type="radio" name="enable_radar" value="0" {if !$store.enable_radar}checked="checked"{/if} />
					                {$lang.no}</label></td>
                             </tr>
                             <!-- goods radar -->
                             {/if}
                             <tr>
                                <th class="align3"><b class="padding1">*</b>店铺介绍:</th>
                                <td>
                                <div class="editor"><div>
                                    <textarea name="description" id="description" style="width:100%; height:350px;">{$store.description|escape}</textarea></div>
                                   <div style=" position: relative; top: 10px; z-index: 5;"><a class="btn3" id="open_editor_uploader">{$lang.uploadedfile}</a>
                                   <div class="upload_con" id="editor_uploader" style="display:none">
                                            <div class="upload_con_top"></div>
                                            <div class="upload_wrap">
                                                <ul>
                                                    <li>
                                                        <div id="divSwfuploadContainer">
                                                            <div id="divButtonContainer">
                                                                <span id="editor_upload_button"></span>
                                                            </div>
                                                        </div>
                                                    </li>
                                                    <li id="open_editor_remote" class="btn4">{$lang.rem_upload}</li>
                                                </ul>
                                                <div id="editor_remote" class="upload_file" style="display:none">
                                                <iframe src="index.php?app=comupload&act=view_remote&id={$id}&belong={$belong}&instance=desc_image" width="272" height="39" scrolling="no" frameborder="0"></iframe>
                                                </div>
                                                <div id="editor_upload_progress"></div>
                                                <div class="upload_txt">
                                                    <span>支持JPEG和静态的GIF格式图片，不支持GIF动画图片，上传图片大小不能超过500KB,建议尺寸宽度为800像素,浏览文件时可以<font color="red">按住ctrl或shift键多选</font></span>
                                                </div>

                                            </div>
                                            <div class="upload_con_bottom"></div>
                                        </div>
                                    </div>
                                    <ul id="desc_images" class="preview">
                                        <!--{foreach from=$files_belong_store item=file}-->
                                        <li ectype="handle_pic" file_name="{$file.file_name|escape}" file_path="{$file.file_path}" file_id="{$file.file_id}">
                                        <input type="hidden" name="file_id[]" value="{$file.file_id}">
                                            <div class="pic">
                                            <img src="{$site_url}/{$file.file_path}" width="50" height="50" alt="{$file.file_name|escape}" title="{$file.file_name|escape}" /></div>
                                            <div ectype="handler" class="bg">
                                            <img src="{$site_url}/{$file.file_path}" width="50" height="50" alt="{$file.file_name|escape}" title="{$file.file_name|escape}" />
                                                <p class="operation">
                                                    <a href="javascript:void(0);" class="cut_in" ectype="insert_editor" ecm_title="{$lang.insert_editor}"></a>
                                                    <span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span>
                                                </p>
                                                <p title="{$file.file_name|escape}" class="name">{$file.file_name|escape}</p>
                                            </div>
                                        </li>
                                        <!--{/foreach}-->
                                    </ul>
                                    <div class="clear"></div>
                                    </div>
                                    <div class="issuance"><input type="submit" class="btn b-radius" value="{$lang.submit}" /></div>
                                 </td>
                             </tr>
                         </table>
                         </div>
                         </form>
          </div>
        </div>
      </div>
	</div>
    <!-- 页脚 -->
{include file=footer.html}